package com.callbox.frontend;

import com.callbox.R;

import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class ValidateNumber extends Activity {
	
	EditText txtNumber;
	EditText txtCode;
	Button btnEnter;
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.validate_number);
		
		txtNumber = (EditText)findViewById(R.id.txtNumber);
		txtCode = (EditText)findViewById(R.id.txtCode);
		btnEnter = (Button) findViewById(R.id.btnEnter);
	}
	
	public void btnEnter_onClick(View v)
	{
		if(btnEnter.getText().toString().equals("Enviar"))
		{
			if(!txtNumber.getText().toString().equals(""))
			{
				//Enviar al servicio y devolver codigo de autorizacion
				txtNumber.getText();
				txtCode.setText("1234");
				btnEnter.setText("Ingresar");
			}
			else
			{
				android.app.AlertDialog.Builder dBuilderRes = new android.app.AlertDialog.Builder(this);	
				
				dBuilderRes.setMessage("Ingrese su numero de telefono");
				dBuilderRes.setNeutralButton("OK",
					new OnClickListener() {
							public void onClick(android.content.DialogInterface arg0,int arg1) {
															
							}
				});
				
				dBuilderRes.create().show();
			}
		}
		else
		{
			if(btnEnter.getText().toString().equals("Ingresar"))
			{
				if(!txtCode.getText().toString().equals(""))
				{
					//Validar codigo de autorizacion en el server
					Intent intent = new Intent(ValidateNumber.this, MainDashboard.class);
					startActivity(intent);
				}			
			}
		}
		
	}
}
